// idf.py add-dependency "espressif/led_strip^3.0.0"
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "led_strip.h"
#define LED_STRIP_GPIO_PIN 6
#define LED_STRIP_LED_COUNT 12
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
typedef enum
{
    KEY_0,
    KEY_1,
    KEY_2,
    KEY_3,
    KEY_4,
    KEY_5,
    KEY_6,
    KEY_7,
    KEY_8,
    KEY_9,
    KEY_SHARP,
    KEY_M,
    KEY_NO
} Touch_Key;
led_strip_handle_t led_strip;
void WS2812_Init(void)
{
    led_strip_config_t strip_config = {
        .strip_gpio_num = LED_STRIP_GPIO_PIN,
        .max_leds = LED_STRIP_LED_COUNT,
        .led_model = LED_MODEL_WS2812,
        .color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_GRB,
        .flags = {
            .invert_out = false,
        }};
    led_strip_rmt_config_t rmt_config = {
        .clk_src = RMT_CLK_SRC_DEFAULT,
        .resolution_hz = LED_STRIP_RMT_RES_HZ,
        .mem_block_symbols = 64,
        .flags = {
            .with_dma = false,
        }};
    led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip);
}
void WS2812_AllOn(void)
{
    led_strip_clear(led_strip);
    for (int i = 0; i < LED_STRIP_LED_COUNT; i++)
    {
        led_strip_set_pixel(led_strip, i, 255, 255, 255);
    }
    led_strip_refresh(led_strip);
}
void WS2812_AllOff(void)
{
    led_strip_clear(led_strip);
    led_strip_refresh(led_strip);
}
void WS2812_On(Touch_Key key)
{
    led_strip_clear(led_strip);
    led_strip_set_pixel(led_strip, key, 255, 255, 255);
    led_strip_refresh(led_strip);
}
void app_main(void)
{
    WS2812_Init();
    WS2812_AllOn();
    WS2812_AllOff();
    WS2812_On(KEY_0);
    while (1)
    {
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}